package com.yc.spring.bank.biz;

import com.yc.spring.bank.bean.Account;
import com.yc.spring.bank.bean.Record;
import com.yc.spring.bank.dao.AccountDao;
import com.yc.spring.bank.dao.RecordDao;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

//@Service
public class BankBizImpl implements BankBiz {

    @Resource
    AccountDao accountDao;  //使用接口类型定义变量
    @Resource
    RecordDao recordDao;//不建议使用实现类类型定义变量

    @Override
    public void register(Account account) {

    }

    @Override
    public void deposit(Integer id, double money) {
        //省略参数验证
        Account account = accountDao.selectById(id);
        account.setMoney(account.getMoney()+ money);
        accountDao.update(account);
        Record record = new Record();
        record.setAccountId(id);
        record.setMoney(money);
        recordDao.insert(record);

    }

    @Override
    public void withdraw(Integer id, double money) {

    }

    @Override
    public void transfer(Integer id1, Integer id2, double money) {

    }

    @Override
    public List<Record> query(Integer id) {
        return null;
    }
}
